package com.itcg.springboot01change.mapper;

import com.itcg.springboot01change.pojo.Account;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

//操作账户Account类的持久层接口
public interface AccountMapper {
    /**
     * 添加账户
     *
     * @param account
     */
    void insert(Account account);

    /**
     * 根据id删除账户
     *
     * @param id
     */
    @Delete("delete from account where id =#{id};")
    void delete(@Param("id") Integer id);

    /**
     * 根据id修改账户
     *
     * @param account
     */
    void update(Account account);

    /**
     * 查询所有账户
     *
     * @return
     */
    @Select("select * from account;")
    List<Account> selectAll();

    /**
     * 根据id查询账户
     *
     * @param id
     * @return
     */
    @Select("select * from account where id =#{id} ")
    Account selectById(@Param("id") Integer id);

    /**
     * 根据账户名称查询账户
     *
     * @param name
     * @return
     */
    @Select("select * from account where name =#{name} ")
    Account selectByName(@Param("name") String name);

    /**
     * 分页
     *
     * @param homeAddress   显示每一页显示的数据
     * @param StartingIndex 起始索引
     * @param pageSize      每页显示记录数
     * @return List<Account>集合
     */
    List<Account> finaPageAccount(@Param("homeAddress") String homeAddress,
                                  @Param("StartingIndex") Integer StartingIndex,
                                  @Param("pageSize") Integer pageSize);

    /**
     * 总记录数
     *
     * @param homeAddress 要查询的数据
     * @return
     */
    Long findCount(String homeAddress);


}

